<?php

class Api_Json extends Api
{
    protected $extensionFiles = 'json';

    public function getOptions($url, $authorization)
    {
        $options = array(
            CURLOPT_URL            => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER     => array(
                'Accept: application/json',
                'Content-Type: application/json',
                'Authorization: Basic ' . $authorization
            ),
        );

        return $options;
    }

    public function encodeData($data, $type = 'issue')
    {
        if ($type !== false) {
            $data = json_encode(array(
                $type => $data,
            ));
        }

        if (!$data) {
            return null;
        }

        return json_encode($data, true);
    }


    public function decodeData($data)
    {
        return json_decode($data, true);
    }


}